package com.justgame.project.service.system.service.basic;

import com.justgame.project.service.system.entity.SysRoleInfo;
import com.justgame.project.service.system.query.SysRoleInfoQuery;
import com.justgame.project.service.system.wrapper.SysRoleInfoWrapper;
import com.justgame.project.base.servcice.IBasicService;
import org.springframework.util.Assert;
import java.lang.Integer;
import org.springframework.lang.NonNull;
import java.lang.String;

/**
 *
 * 角色表服务自定义查询类
 *
 * @@tableName sys_role_info
 * @author Zwb
 */
@SuppressWarnings("all")
public interface BasicSysRoleInfoService extends IBasicService<SysRoleInfoQuery,SysRoleInfo,SysRoleInfoWrapper> {

   /**
    * 新增创建
    * @param name 名称
    * @param description 描述
    * @param weight 权重
    */
   default SysRoleInfo baseAdd(String name, String description, Integer weight){
      SysRoleInfo sysRoleInfo = new SysRoleInfo();
      sysRoleInfo.setName(safeValue(name, null));
      sysRoleInfo.setDescription(safeValue(description, null));
      sysRoleInfo.setWeight(safeValue(weight, null));
      save(sysRoleInfo);
      return sysRoleInfo;
   }

   /**
    * 更新
    * @param name 名称
    * @param description 描述
    * @param weight 权重
    */
   default boolean baseUpdate(@NonNull SysRoleInfo sysRoleInfo,String name, String description, Integer weight){
      Assert.notNull(description,"必须提供描述");
      Assert.notNull(weight,"必须提供权重");
      Assert.notNull(name,"必须提供名称");
      Assert.notNull(sysRoleInfo.getId(),"必须提供主键ID");
      sysRoleInfo.setName(safeValue(name, null));
      sysRoleInfo.setDescription(safeValue(description, null));
      sysRoleInfo.setWeight(safeValue(weight, null));
      return updateById(sysRoleInfo);
   }

}